<template>
    <div class="header">
      <div class="left">
        <div v-show="flag" class="leonardo">
          <img src="../../public/img/Leonardo.jpg" alt="" />
        </div>
        
        <div v-show="flag" class="kwhMsg">
          <span :class="topMsg.kwh"></span>
          <span v-show="topMsg.hasOwnProperty('kwhtext')" class="text">
            {{ topMsg.kwhtext }}
          </span>
        </div>

        <span v-show="!flag" @click="back" class="iconfont icon-fanhuijiantou jia"></span>
      </div>

      <div class="name" v-show="topMsg.hasOwnProperty('name')">
        {{ topMsg.name }}
      </div>
      <!-- <div class="name">消息</div> -->

      <div :class="topMsg.rightIco"></div>
    </div>
    <div v-show="flag" class="search">
      <span class="iconfont icon-sousuo searIco"></span>
      <span>搜索</span>
    </div>
</template>

<script>
import { useRouter} from 'vue-router'
export default {
  name: "Header",
  props: ["topMsg","flag"],
  setup() {
    const router = useRouter()
    const back = () => {
      router.go(-1)
    }
    return {
      back
    }
  }
  
};
</script>

<style>

.header {
  position: fixed;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 45px;
  padding: 15px 10px 14px 10px;
  box-sizing: border-box;
  background-color: #12b7f5;
  z-index: 3;
}

.left {
  display: flex;
  /* width: 145px; */
  height: 30px;
  /* line-height: 30px; */
  position: relative;
}

.leonardo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
}
.left .kwhMsg {
  width: max-content;
  position: absolute;
  display: flex;
  left: 40px;
  top: 20px;
}

.text {
  font-size: 10px;
  color: #fff;
}

.kwh {
  font-size: 15px;
  color: rgb(46, 233, 46);
}

.leonardo img {
  width: 100%;
  height: 100%;
}

.jia {
  font-size: 23px;
  color: #fff;
}

.name {
  font-size: 15px;
  color: #fff;
}

.search {
  width: 355px;
  height: 30px;
  margin: 10px;
  margin-top: 55px;
  margin-bottom: 15px;
  border-radius: 50px;
  background-color: rgb(236, 239, 239);
}

.search span{
  line-height: 30px;
}

.search .searIco {
  margin-left: 150px;
  margin-right: 3px;
  font-size: 16px;
  color: #ccc;
}
</style>